<template>
  <el-select
    v-model="value"
    :filterable="filterable"
    :clearable="clearable"
    :multiple="multiple"
    placeholder="请选择"
    @change="changeVal">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
</template>

<script>
export default {
  name: 'xnzw-select',
  data () {
    return {
      value: ''
    }
  },
  // 传递到子组建中的值
  props: {
    options: {
      type: Array,
      default: function () {
        return []
      }
    },
    // 是否过滤
    filterable: {
      type: Boolean,
      default: false
    },
    // 是否多选
    multiple: {
      type: Boolean,
      default: false
    },
    // 是否带有清空按钮
    clearable: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    // 选择值改变时触发的方式
    changeVal: function () {
      this.$emit('change', this.value)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>

</style>
